import Mock from "mockjs";



// 从缓存中拿到用户信息
/**
 * 获取推广员信息
 * @param {string} id - 用户id
 * @returns {Promise<SaleInfo>}
 */
export const getSaleInfo = async (id) => {
    const res = await Mock.mock({
        "id": id,
        "avatar": "@image('100x100')",
        "name": "@cname",
        "saleType|1":[1,2],
    })
    return res;
}

/**
 * 获取业绩数据统计
 * @param {string} id - 用户id
 * @returns {Promise<SaleInfo>}
 */
export const getSaleData = async (id) => {
    const res = await Mock.mock({
        "totalReward": "@integer(100, 1000)",
        "inviteNum": "@integer(0, 20)",
    })
    return res;
}

/**
 * 提交线索
 * @param {object} params
 * @param {string} params.name - 姓名
 * @param {string} params.phone - 手机号
 * @param {string} params.address - 地址
 * @param {string} params.user_id - 上报人id
 * @param {string} params.comment - 备注 
 * @returns 
 */
export const addClue = async (params) => {
    const res = await Mock.mock({
        "code": 0
    })
    return res;
}

/**
 * 获取用户提交的线索列表
 * @param {object} params
 * @param {string} params.user_id -- 用户id
 * @param {string} params.name -- 名称
 * @param {string} params.pageNo -- 页码
 * @param {string} params.pageCount -- 页数
 * @returns {Promise<ClueList[]>}  
 */
export const getUserClue = async (params) => {
    const res = await Mock.mock({
        "data|10": [
            {
                "id|+1": 1,
                "name": "@cname",
                "phone": "@integer(10000000000, 19999999999)",
                "createTime": 1689091200000
            }
        ]
    })
    return res.data;
}

/**
 * 获取业绩数据明细
 * @param {object} params
 * @param {string} params.user_id -- 用户id
 * @param {string} params.state -- 结算状态
 * @param {string} params.type -- 奖励类型
 * @param {string} params.pageNo -- 页码
 * @param {string} params.pageCount -- 页数
 *  
 */
export const getSaleDataDetail = async (params) => {
    const res = await Mock.mock({
        "data": {
            "list|10": [
                {
                    "id|+1": 1,
                    "skuName": "@cname",
                    "finishTime": 1689091200000,
                    "payPrice": "@integer(100, 1000)",
                    "name": "@cname",
                    "checkoutAmount": "@integer(100, 1000)",
                    "checkoutBonus":"0.5"
                }
            ],
            "total": 100,
            "price": "@integer(100, 1000)"
        }
    })
    return res;
}


/**
 * 获取邀请人数明细
 * @param {object} params
 * @param {string} name -- 用户名称
 * @param {number} params.pageNo -- 页码
 * @param {number} params.pageCount -- 页数
 *  
 */
export const getInviteUserNum = async (params) => {
    const res = await Mock.mock({
        "data": {
            "list|10": [
                {
                    "id|+1": 1,
                    "name": "@cname",
                    "avatar": "@image('100x100')",
                    "createTime": 1689091200000
                }
            ],
            "total": 100
        }
    })
    return res;
}